package com.nauu.atombuilder.editors;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.part.MultiPageEditorPart;


public class MultiFormEditor extends MultiPageEditorPart{

	@Override
	public void init(IEditorSite site, IEditorInput input)
			throws PartInitException {
		super.init(site, input);
		setPartName(input.getName());
	}
	
	@Override
	protected void createPages() {
		try {
			int index = addPage(new CustomFormEditor(),getEditorInput());
			setPageText(index, "desgin");
			index = addPage(new TextEditor(),getEditorInput());
			setPageText(index, "source");
		} catch (PartInitException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void doSave(IProgressMonitor monitor) {
		((CustomFormEditor)getEditor(0)).doSave(monitor);
	}

	@Override
	public void doSaveAs() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean isSaveAsAllowed() {
		return true;
	}

}
